<div xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  xmlns:nxd="http://nuxeo.org/nxweb/document"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  class="repoInfos">


 <c:if test="#{!systemInfo.isMultiRepo()}">
  <nxu:set var="repo" value="#{systemInfo.listAvailableRepositories().get(0)}">
    <p><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.repositoryinfo.2']}" />: <b>#{messages[repo.label]} (#{repo.name})</b></p>
  </nxu:set>
 </c:if>

 <a4j:outputPanel id="repoInfos" layout="block">
  <p><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.openconnection.1']} #{systemInfo.openSessionNumber} #{messages['adminsubtab.sysinfo.repostat.openconnection.2']}" /></p>

  <p><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.activeconnection']} #{systemInfo.activeSessionNumber}" /></p>

  <p>
    <h:form id="repoInfoForm">

     <a4j:poll interval="1000" enabled="#{systemInfo.isStatInfoInProgress()}" render="repoInfos"/>

     <h:panelGroup rendered="#{systemInfo.isStatInfoInProgress()}">
       <div class="processMessage running"><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.computing']}" /> </div>
     </h:panelGroup>

     <h:panelGroup rendered="#{!systemInfo.isStatInfoInProgress()}">

        <a4j:commandButton value="#{messages['adminsubtab.sysinfo.repostat.compute.statistics']}"  action="#{systemInfo.startRepoStats()}" render="repoInfos" styleClass="button" />

     </h:panelGroup>
    </h:form>
  </p>

  <div>
    <h:panelGroup rendered="#{systemInfo.isStatInfoAvailable()}">
      <table class="dataOutput">
        <tr>
        <th><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.generalstatsistics']}" /></th>
        <th><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.perdocumenttypes']}" /></th>
        </tr>
        <tr>
         <td>
        <table>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.numberofdocuments']}" /></td>
             <td>
             <h:outputText value="#{repoStatResult.getTotalNbDocs()}">
               <f:convertNumber type="number"/>
             </h:outputText>
               </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.numberofversions']}" />: </td>
             <td>
             <h:outputText value="#{repoStatResult.getVersions()}">
               <f:convertNumber type="number"/>
             </h:outputText>
               </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.numberofblobs']}" /></td>
             <td>
             <h:outputText value="#{repoStatResult.getTotalBlobNumber()}">
               <f:convertNumber type="number"/>
             </h:outputText>
             </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.totalsizeofblobs']}" />:</td>
             <td>
                <h:outputText value="#{repoStatResult.getTotalBlobSize()/(1024*1024)}">
                    <f:convertNumber type="number" maxFractionDigits="3"/>
                  </h:outputText>
             </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.maxtreedepth']}" /></td>
             <td> #{repoStatResult.getMaxDepth()} </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.maxblobsize']}" /></td>
             <td>
                  <h:outputText value="#{repoStatResult.getMaxBlobSize()/1024}">
                    <f:convertNumber type="number" maxFractionDigits="1"/>
                  </h:outputText>
              </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.biggestfolder']}" />:</td>
             <td> #{repoStatResult.getMaxChildren()} children </td>
          </tr>
          <tr>
             <td><h:outputText value="#{messages['adminsubtab.sysinfo.repostat.averagereadspeed']}" />: </td>
             <td>
                  <h:outputText value="#{repoStatResult.getSpeed()}">
                    <f:convertNumber type="number" maxFractionDigits="1"/>
                  </h:outputText>
              </td>
          </tr>
        </table>
       </td>
       <td>
          <table>
          <nxu:repeat value="#{repoStatResult.getDocTypes()}" var="docType">
            <tr>
               <td> #{docType} </td>
               <td>
                  <h:outputText value="#{repoStatResult.getDocTypeCount(docType)}">
                    <f:convertNumber type="number"/>
                  </h:outputText>
               </td>
            </tr>
          </nxu:repeat>
         </table>
       </td>
       </tr>
     </table>
   </h:panelGroup>
  </div>

</a4j:outputPanel>

</div>
